<?php

include 'confidential_settings_heliohost.php';
// This include contains 5 variables:
//  - db_name: database name
//  - table_name_x: table name
//  - username: username
//  - password: password
//  - localhost: host name

$dbh=mysql_connect ($localhost, $username, $password) or die('Cannot connect to the database because: ' . mysql_error());

mysql_select_db ($db_name) or die(mysql_error()); 

$result = mysql_query("SELECT COUNT(val), DATE(date_entered + SEC_TO_TIME(28800)) as date_value, SUM(val) FROM $table_name_gsc WHERE DATE_SUB(CURDATE(),INTERVAL 3 MONTH) <= DATE(date_entered) GROUP BY YEAR(DATE(date_entered)), MONTH(DATE(date_entered)), DAY(DATE(date_entered))");

echo "<br /><br />DAY VALUES:<br />";
while($row = mysql_fetch_array($result)){
	echo $row['date_value'] . "\t" . $row['SUM(val)'] . "\t   (" . $row['COUNT(val)'] . " entries)";
	echo "<br />";
}

echo "<br />";

$result = mysql_query("SELECT val, (date_entered) AS date_converted FROM $table_name_gsc_ns");
 
echo "<br /><br />DETAILED VALUES (NO SUCCEED TABLE):<br />";
while($row = mysql_fetch_array($result)){
	echo $row['val'] . " - " . $row['date_converted'];
	echo "<br />";
}

echo "<br />";

$result = mysql_query("SELECT val,  (date_entered + SEC_TO_TIME(28800)) as date_converted FROM $table_name_gsc WHERE DATE_SUB(CURDATE(),INTERVAL 3 MONTH) <= DATE(date_entered)");
 
echo "<br /><br />DETAILED VALUES:<br />";
while($row = mysql_fetch_array($result)){
	echo $row['val'] . " - " . $row['date_converted'];
	echo "<br />";
}


mysql_close($dbh);

?>
